from tortoise import fields
from .base import BaseModel, TimestampMixin

class JobsRule(BaseModel, TimestampMixin):
    type = fields.IntField(default=1, description="任务类型", index=True)
    name = fields.CharField(max_length=255,description="任务标题")
    func_name = fields.CharField(max_length=255, description="访问url")
    times = fields.IntField(default=0,null=True,  description="执行间隔(秒)")
    day = fields.IntField(default=0,null=True,  description="天")
    hour = fields.IntField(default=0,null=True,  description="时")
    minute = fields.IntField(default=0,null=True,  description="分")
    second = fields.IntField(default=0, null=True, description="秒")
    state = fields.BooleanField(default=False, description="执行状态")
    up_type = fields.IntField(default=1, null=True, description="启动方式1自启动2手动启动")
    class Meta:
        table = "jobs_rule"

class JobsLog(BaseModel, TimestampMixin):
    user_id = fields.IntField(default=0, description="关联人id")
    job_id = fields.IntField(default=0, description="任务id")
    result_status = fields.IntField(default=0, null=True, description="执行结果1成功2失败")
    result_data = fields.TextField(null=True, description="执行返回数据")
    class Meta:
        table = "jobs_log"